<?php
//引入链接 conn.php
require_once './conn.php';



//获取id从数据库 所有字段信息
if (count($_POST)>0) {
    mysqli_query($link,"UPDATE users set name='".$_POST['username']."',
    mobile='".$_POST['mobile']."',
    email='".$_POST['email']."'WHERE id='".$_POST['id']."'");
    header("location:index.php");
    exit();
}
//获取链接传递的数据 id
$id=$_GET['id'];
//构造sql select* from users where id=?
$sql="select * from users where id ='".$id."'";
$result = mysqli_query($link,$sql);


$row=mysqli_fetch_array($result);

// var_dump($row);
//把数据放在表单 value
//UI界面

?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="./css/bootstrap.css">
  <title>修改记录</title>
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <div class="my-3">
          <h1>修改记录</h1>
        </div>
        <form method="post" action="">
          <div class="form-group">
            <label for="username">姓名</label>
            <input type="text" class="form-control" id="username" name="username" value="<?php echo $row['name'];?>" maxlength="50" required="">
          </div>
          <div class="form-group">
            <label for="email">邮箱</label>
            <input type="text" class="form-control" id="email" name="email" value="<?php echo $row['email'];?>" maxlength="30"
              required="">
          </div>
          <div class="form-group">
            <label for="mobile">电话号码</label>
            <input type="text" class="form-control" id="mobile" name="mobile" value="<?php echo $row['mobile'];?>" maxlength="30"
              required="">
          </div>
          <input type="hidden" name="id" value="<?php echo $row['id'];?>">
          <input type="submit" class="btn btn-primary" value="修改">
          <a href="./index.php" class="btn btn-success">返回首页</a>
        </form>
      </div>
    </div>
  </div>
</body>

</html>